import Vue from 'vue'
// 引入路由插件
import Router from 'vue-router'
// 添加登录页的组件
import Login from './views/Login.vue'
// 添加Home页组件
import Home from './views/Home.vue'
// 添加欢迎页组件
// import welcome from './views/Welcome.vue'
// 使用路由插件
Vue.use(Router)

export default new Router({
  routes: [
    // 设置登录组件的路由规则
    {
      path: '/login',
      name: 'login',
      component: Login
    },
    // 设置首页的路由规则
    {
      path: '/',
      name: 'home',
      component: Home,
      // 设置默认一打开页面就加载欢迎页面
      redirect: '/Welcome',
      children: [
        // 设置首页的欢迎页的子路由规则
        {
          path: 'welcome',
          name: 'welcome',
          // route level code-splitting
          // this generates a separate chunk (about.[hash].js) for this route
          // which is lazy-loaded when the route is visited.
          component: () => import(/* webpackChunkName: "welcome" */ './views/Welcome')
        },
        {
          // 设置用户列表页面
          path: 'users',
          name: 'users',
          // route level code-splitting
          // this generates a separate chunk (about.[hash].js) for this route
          // which is lazy-loaded when the route is visited.
          component: () => import(/* webpackChunkName: "users" */ './views/Userlist')
        },
        {
          // 设置权限管理xx列表
          path: 'rights',
          name: 'rights',
          // route level code-splitting
          // this generates a separate chunk (about.[hash].js) for this route
          // which is lazy-loaded when the route is visited.
          component: () => import(/* webpackChunkName: "rights" */ './views/auth/RightList.vue')
        },
        {
          // 设置权限管理xx列表
          path: 'roles',
          name: 'roles',
          component: () => import(/* webpackChunkName: "roles" */ './views/auth/Roles.vue')
        },
        {
          // 设置商品管理-商品分类
          path: 'categories',
          name: 'categories',
          component: () => import(/* webpackChunkName: "categories" */ './views/goods/Categories.vue')
        }
      ]
    }

  ]
})
